package com.world.rickcloudendpoint.models.mongo;

import com.world.rickcloudendpoint.common.utils.DateTimeUtils;
import com.world.rickcloudendpoint.common.utils.NumberUtils;
import com.world.rickcloudendpoint.models.vo.ASignalVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

/**
 * @description: a 信号信息
 * @author: jlsong
 * @date: 2022/01/22 20:35:42
 * @version: 1.0
 */
@Data
@ApiModel(value = "aSignalDoc", description = "A信号体")
@Document("rc_aSignal")
public class ASignalDoc {

    @Id
    private ObjectId _id;

    @ApiModelProperty("数据类型编号")
    private String typeSerial;

    @ApiModelProperty("数据所属实验号")
    private String experimentNo;

    @ApiModelProperty("报文发送时间-年")
    private int sendYear;

    @ApiModelProperty("报文发送时间-月")
    private short sendMonth;

    @ApiModelProperty("报文发送时间-日")
    private short sendDay;

    @ApiModelProperty("报文发送时间-小时")
    private short sendHour;

    @ApiModelProperty("报文发送时间-分")
    private short sendMin;

    @ApiModelProperty("报文发送时间-秒")
    private short sendSec;

    @ApiModelProperty("报文发送时间")
    private long sendTime;

    @ApiModelProperty("站号，来源")
    private String stationNo;

    @ApiModelProperty("批号")
    private String batchNo;

    @ApiModelProperty("经度，1e-6，单位：度")
    private long lon;

    @ApiModelProperty("纬度，1e-6，单位：度")
    private long lat;

    @ApiModelProperty("高度，1e-2，单位：米")
    private long alt;

    @ApiModelProperty("航速，1e-2，单位：km/h")
    private long speed;

    @ApiModelProperty("航向，1e-2，单位：度")
    private long heading;

    @ApiModelProperty("目标种类")
    private String targetType;

    @ApiModelProperty("目标属性")
    private String targetAttr;

    @ApiModelProperty("目标识别号")
    private String targetSerial;

    public ASignalVO toVo() {
        ASignalVO vo = new ASignalVO();
        if (this._id != null) {
            vo.setId(this._id.toString());
        }
        DateTimeUtils.YmdHmsMillis yhm = new DateTimeUtils.YmdHmsMillis(this.sendYear, this.sendMonth, this.sendDay, this.sendHour, this.sendMin, this.sendSec, 0);
        long timestamp = DateTimeUtils.ymdHmsMillisToTimeStamp(yhm, DateTimeUtils.chinaZone);
        vo.setSendTime(timestamp);

        vo.setLon(NumberUtils.longToDouble(this.lon, -6));
        vo.setLat(NumberUtils.longToDouble(this.lat, -6));
        vo.setAlt(NumberUtils.longToDouble(this.alt, -2));
        vo.setSpeed(NumberUtils.longToDouble(this.speed, -2));
        vo.setHeading(NumberUtils.longToDouble(this.heading, -2));

        vo.setTypeSerial(this.typeSerial);
        vo.setExperimentNo(this.experimentNo);
        vo.setStationNo(this.stationNo);
        vo.setBatchNo(this.batchNo);
        vo.setTargetType(this.targetType);
        vo.setTargetAttr(this.targetAttr);
        vo.setTargetSerial(this.targetSerial);

        return vo;
    }
}
